<template>
  <section class="component">
    <data-box :data="dataSetList" @onPageChange="refreshData">
      <template slot="columns">
        <el-table-column prop="operatorRealName" label="操作人" :min-width="$helper.getColumnWidth(3)">
        </el-table-column>
        <el-table-column prop="timeCreated" :formatter="row => $filter.dateTimeFormat(row.timeCreated)" label="操作时间" :min-width="$helper.getColumnWidth(5)">
        </el-table-column>
        <el-table-column prop="changeType" label="变更类型" :formatter="(row) => $filter.dictConvert(row.changeType,'OperateType')" :min-width="$helper.getColumnWidth(4)">
        </el-table-column>
        <el-table-column prop="applyStatus" label="审批状态" :min-width="$helper.getColumnWidth(4)">
          <template slot-scope="scope">
            <div v-if="scope.row.changeType==='CREATE'">- - -</div>
            <div v-else> {{$filter.dictConvert(scope.row.applyStatus,'ApplyStatus')}}</div>
          </template>
        </el-table-column>
        <el-table-column label="操作" :min-width="$helper.getColumnWidth(4)">
          <template slot-scope="scope">
            <el-button @click="showInfo(scope)" type="text">查看详情</el-button>
          </template>
        </el-table-column>
      </template>
    </data-box>

    <el-dialog title="分案日期策略日志" :visible.sync="dialog.seeLog" width="700px" :close-on-click-modal="false" @open="$nextTick(() => $refs['add-division'].reset())" :close-on-press-escape="false" append-to-body>
      <add-division :roleData="roleObj" :num="num" @close="dialog.seeLog = false" @refreshList="refreshData" ref="add-division"></add-division>
    </el-dialog>
  </section>
</template>

<script lang="ts">
import Vue from "vue";
import Component from "vue-class-component";
import { Dependencies } from "~/core/decorator";
import { Prop, Watch } from "vue-property-decorator";
import AddDivision from '~/components/strategic-manage/add-division.vue';
import { DateStrategyService } from '~/services/management-service/date-strategy.service';
@Component({
  components: {
    AddDivision
  }
})
export default class DivisionLog extends Vue {
  @Dependencies(DateStrategyService)
  private dateStrategyService: DateStrategyService;
  @Prop({
    type: Object
  })
  private modifyData: any;
  private num: number = 2
  private roleObj: any = {}
  private disabled: any = true
  private dialog: any = {
    seeLog: false
  }
  private dataSetList: any = []
  private model: any = {
    parentId: ""
  };
  private showInfo (scope) {
    // 查看时
    const row = { ...scope.row }
    const rowItem = row.operationDate.split(',').map(f => {
      if (f.indexOf('号') === -1) { f += '号' }
      return f
    })
    row.editOperationDate = rowItem
    this.roleObj = row
    this.dialog.seeLog = true;
  }
  private refreshData () {
    this.model.parentId = this.modifyData.id;
    this.dateStrategyService
      .findDateStrategyLog(this.model)
      .subscribe(data => {
        this.dataSetList = data;
        console.log(data);

      });
  }
}
</script>

<style>
</style>